<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CompleteSetup.aspx.cs" Inherits="CompleteSetup" Title="Untitled Page" %>
<%@ Register Assembly="Decav.Web" Namespace="Decav.Web.Controls" TagPrefix="decav" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceholder" Runat="Server">
    <script language="javascript" type="text/javascript">
    // <!--
    
        function CreateAccount_AppendText(box, msg)
        {
            box.appendChild(document.createTextNode(msg));
        }
    
        function CreateAccount_ValidateSubmission()
        {
            var nametb = document.getElementById("<%= nameTextBox.ClientID %>");
            var emailtb = document.getElementById("<%= emailTextBox.ClientID %>");
            var ziptb = document.getElementById("<%= postalCodeTextBox.ClientID %>");
            var tosck = document.getElementById("<%= termsOfUseCheck.ClientID %>");
            
            var validMsg = document.getElementById("validateMsg");
            for (var i=validMsg.childNodes.length-1; i>=0; i--)
                validMsg.removeChild(validMsg.childNodes[i]);
            
            if (nulltb(nametb) || nulltb(emailtb))
            {
                CreateAccount_AppendText(validMsg, "All the fields are required.");
                return false;
            }
                                    
            if (tosck.checked != "checked" && tosck.checked != true && tosck.checked != "true")
            {
                CreateAccount_AppendText(validMsg, "Please accept our terms of use before continuing.");
                return false;
            }
            
            if(nametb.value.split(" ").length < 2 || nametb.value.length < 8)
            {
                CreateAccount_AppendText(validMsg, "Please supply us with your full name.  You may use an initial for your last name.");
                return false;
            }
            
            if (nulltb(ziptb, 5))
            {
                CreateAccount_AppendText(validMsg,  "Please supply us with your home postal code.  We will use this to find locations near you.");
                return false;
            }
            
            return true;
        }
        
        function nulltb(obj, minlen)
        {
            if (minlen == null) minlen = 1;
            return obj.value.length < minlen;
        }
    
    // -->
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PageBodyPlaceholder" Runat="Server">
    <div style="margin-left:235px;margin-right:235px;">
        <h1>Finish Setting Up...</h1>
        <p>
            Thanks for registering with Gatsb on your mobile phone.  We need to ask a few
            more questions to finish setting up your account, and then you can get started.
        </p>
        <div class="StyledForm">
            <div runat="server" id="serverErrorMsgDiv" visible="false" class="ErrorRibbon"></div>
            <p class="NewSection">
                <label for="<%= nameTextBox.ClientID %>">Name</label>
                <asp:TextBox runat="server" ID="nameTextBox" MaxLength="50"/>
            </p>
            <p class="NewSection">
                <label for="<%= emailTextBox.ClientID %>">Email</label>
                <asp:TextBox runat="server" ID="emailTextBox" MaxLength="50"/>
            </p>
            <p>
                <label for="<%= passwordTextBox.ClientID %>">New Password</label>
                <asp:TextBox runat="server" ID="passwordTextBox" TextMode="password" MaxLength="20"/>
            </p>
            <p>
                <label for="<%= confirmPasswordTextBox.ClientID %>">New Password</label>
                <asp:TextBox runat="server" ID="confirmPasswordTextBox" TextMode="password" MaxLength="20"/>
            </p>
            <p class="NewSection">
                <label for="<%= cityDropDown.ClientID %>">City</label>
                <asp:DropDownList runat="server" ID="cityDropDown">
                    <asp:ListItem>New York</asp:ListItem>
                </asp:DropDownList>
                <br />
                <span style="color:#666666;font-style:italic">
                    We currently support a limited number of cities but will be adding more soon!
                </span>
            </p>
            <p class="NewSection">
                <label for="<%= postalCodeTextBox.ClientID %>">Postal Code</label>
                <asp:TextBox runat="server" ID="postalCodeTextBox" MaxLength="5"/>
            </p>
            <p>
                <label for="<%= birthdayBox.ClientID %>">Birthday</label>
                <decav:DateSelectionBox runat="server" ID="birthdayBox" /> <span style="color:#666666;font-style:italic">(Month/Day/Year)</span>
            </p>
            <p class="NoFormat">
                <asp:CheckBox runat="server" ID="termsOfUseCheck" />
                <label for="<%= termsOfUseCheck.ClientID %>">I have read and accept the <a href="TermsOfUse.aspx">terms of use</a></label>
            </p>
            <div style="text-align:right;">
                <div id="validateMsg" class="ErrorMessage" style="text-align:left;padding-bottom:5px;"></div>
                <asp:Button runat="server" ID="submitButton" OnClick="SubmitButton_Click"
                    UseSubmitBehavior="true" Text="Join Gatsb" 
                    OnClientClick="if(CreateAccount_ValidateSubmission() == false) return false;this.enabled = false;" />
            </div>
        </div>
    </div>
</asp:Content>

